import Vue from 'vue'
import Vuex from 'vuex'
import {getItem,setItem,removeItem} from '@/utils/localfun'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    logintoken:getItem('logintoken'),
    hislist:getItem('hissearch')||[],
  },
  mutations: {
    addtoken(state,data){
      state.logintoken=data
      setItem('logintoken',data)
    },
    delallhistory(state){
      state.hislist=[],
      setItem('hissearch',state.hislist)
    },
    delthehistory(state,data){
      console.log(data)
      state.hislist.splice(data,1)
      setItem('hissearch',state.hislist)
    },
    hisadd(state,data){
      state.hislist.push(data)
      setItem('hissearch',state.hislist)
    }
  },
  actions: {
  },
  modules: {
  }
})
